<template>
	<view class="wrap">
		<js-error mode="bottom" ref="jsError"></js-error>
		<view class="bg-white  padding  margin-bottom" style="height: 80vh;">
			<u-form class="form" :model="model" :rules="rules" ref="uForm" label-position="left" style="padding: 0 10px">
				<u-form-item label="追加次数" prop="iqty" label-width="220" required>
					<u-input placeholder="请输入" v-model="model.iqty" type="text" maxlength="64" ></u-input>
				</u-form-item>
				<u-form-item label="备注信息" prop="remarks" label-width="220" label-position="bottom">
					<u-input placeholder="请输入" v-model="model.remarks" type="textareaAInput" maxlength="64" ></u-input>
				</u-form-item>
			</u-form>	
		</view>
		<view class="form-footer cu-bar foot" v-if="flagBtn">
			<u-button class="btn" @click="cancle">取消</u-button>
			<u-button class="btn" type="primary" @click="submit">确认</u-button>
		</view>
	</view>
	
</template>
<script>
	import { hasPermission } from '@/common/fire.js'
	export default {
		data() {
			return {
				model: {},
				rules: {
					iqty:[
						{
							required: true,
							message: '请输入追加次数',
							trigger: ['change','blur'],
						}
					]
				},
				flagBtn: hasPermission('bas:mold:basMold:edit')
			}
		},
		onLoad(e){
			this.model.selIds = e.selIds
		},
		onReady() {
			//如果需要兼容微信小程序，并且校验规则中含有方法等，只能通过setRules方法设置规则。
			this.$refs.uForm.setRules(this.rules)
		},
		methods: {
			submit(){
				this.$refs.uForm.validate(valid => {
					if (valid) {
						console.log('model',this.model)
						this.$u.api.asd.addUseQty(this.model).then(res => {
							if(res.result == "true"){
								this.$u.toast(res.message);
								setTimeout(()=>{
									uni.navigateTo({
										url: '/pages/asd/mold/add',
									})
								},500)
							}else{
								this.$refs.jsError.showError('', res.message , 'error');
							}
							
						})
					} else {
						this.$u.toast('您填写的信息有误，请根据提示修正。');
					}
				})
			},
			cancle(){
				uni.navigateBack({
					delta: 1
				});
			}
		},
		
	}
</script>
<style lang="scss" scoped>
	.form-footer{
		margin: 0;
	}
</style>